// 菜单管理路由
const express = require('express');
const menuController = require('../controllers/menuController');
const {authMiddleware} = require('../middlewares/authMiddleware');
const { apiPathMiddleware } = require('../middlewares/apiPathMiddleware');

const router = express.Router();

// 获取菜单列表
router.get('/', 
  authMiddleware, 
  apiPathMiddleware('permission'), menuController.getAllMenu);
// 创建菜单
router.post('/save', 
  authMiddleware, apiPathMiddleware('permission/save'), menuController.createMenu);
// 修改菜单
router.put('/update', 
  authMiddleware, apiPathMiddleware('permission/update'), menuController.updateMenu);
// 删除菜单
router.delete('/remove/:id', 
  authMiddleware, apiPathMiddleware('permission/remove'), menuController.removeMenu);
// 获取角色拥有的权限与全部权限
router.get('/toAssign/:roleId', 
  authMiddleware, menuController.toAssign)
// 给角色分配权限
router.post('/doAssign/', 
  authMiddleware, apiPathMiddleware('permission/doAssign'), menuController.doAssign);

module.exports = router;
